<template>
	<view class="apply-box">
		<!-- <uni-nav-bar @clickLeft="goBack" left-icon="left" title="申报状态" color="#ffffff" backgroundColor='#1764CE'
			:border='false'></uni-nav-bar> -->
		<view class="content-box">
			<uni-search-bar @confirm="confirm" @input="inputChange" placeholder="请输入项目申请号" bgColor="#fff"
				style="height: 64rpx;width: 711rpx;" />
			<uni-list>
				<uni-list-item v-for="(item,i) in listData" :key='i' :clickable='true' @click="itemClicked(item)">
					<template v-slot:body>
						<view class="list-item">
							<view class="list-item-top">
								<view class="list-item-name">
									<text style="margin-right: 10rpx;">项目名称:</text>
									<text>{{item.projectName}}</text>
								</view>
								<view class="list-item-statu" v-if="item.auditsStatus">
									<text>{{getStatus(item.auditsStatus)}}</text>
								</view>
							</view>
							<view class="list-item-code">
								<text style="margin-right: 10rpx;">项目申请号:</text>
								<text>{{item.projectNo}}</text>
							</view>
						</view>
					</template>
				</uni-list-item>
			</uni-list>
			<uni-load-more :status="loadStatus"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import request from '@/utils/request.js'
	export default {
		data() {
			return {
				listData: [],
				currentPage: 1,
				total: 0,
				projectNo: '',
				loadStatus: 'no-more',
				userInfo:null,
			};
		},
		onLoad(options) {
			this.userInfo = uni.getStorageSync('userInfo')? JSON.parse(uni.getStorageSync('userInfo')):{}
			this.loadData()
		},
		onReachBottom() {
			if (this.total == this.listData.length) {
				return
			}
			this.currentPage += 1
			this.loadData()
		},
		methods: {
			getStatus(val){
				const status = {
					'-2':"待审核",
					'0':'附件待提交',
					'1':'已提交',
					'2':'审核中',
					'3':'待验收',
					'4':'验收通过',
					'-1':'已驳回',
					'-4':'验收不通过',
				}
				return status[val]
			},
			inputChange(val) {
				this.projectNo = val
				this.currentPage =1
				this.loadData()
			},
			confirm(val) {
				this.projectNo = val.value
				this.currentPage = 1
				this.loadData()
			},
			loadData() {
				let self = this
				let userInfo = uni.getStorageSync('userInfo')
				console.log(userInfo, 'userInfo')
				let userId = userInfo.id
				request.post('/lsydfk/applies/page/query', {
					pageSize: 10,
					currentPage: this.currentPage,
					// projectNo: this.projectNo,
					query: {
						"projectName": "",
						"projectNo": this.projectNo,
						"telephone": "",
						// "userId": userId
					}
				}).then(res => {
					// self.listData = self.listData.concat(res.records)
					if(this.currentPage==1){
						self.listData = res.records
					}else{
						
						self.listData = self.listData.concat(res.records)
					}
					self.total = res.total
				}).catch(err => {

				})
			},
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			itemClicked(val) {
				uni.navigateTo({
					url: '/pages/PageApplyHistory?id=' + val.id
				})
			}
		},
	}
</script>

<style lang="scss">
	.list-box {
		overflow: scroll;
	}

	.list-item {
		// margin: 18rpx 19rpx;
		// background-color: #fff;
		// border-radius: 11rpx;
		// padding: 17rpx 29rpx;
		width: 100%;
		&-top{
			display: flex;
			align-items: flex-start;
			font-size: 31rpx;
			justify-content: space-between;
		}
		&-statu{
			background-color: #1E92F0;
			padding: 3rpx;
			text-align: center;
			border-radius: 30rpx;
			margin-left: 20rpx;
			font-size: 24rpx;
			color: #fff;
			margin-top: 10px;
			min-width: 60px;
		}
		&-name {
			
			color: #3D3D3D;
			line-height: 83rpx;
		}

		&-code {
			font-weight: 400;
			font-size: 31rpx;
			color: #767676;
			line-height: 83rpx;
		}
	}
</style>